<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<head>
    <meta charset="UTF-8">
    <title>admin</title>
</head>
<body>
<div layout:fragment="content">
    <div class="clearfix btn-box">
        <i-button class="note-btn" type="primary" @click="addResource">添加资源</i-button>
        <i-button class="note-btn" type="primary" @click="toRoleList">角色列表</i-button>
        <i-button class="note-btn" type="primary" @click="userList">用户列表</i-button>
    </div>
    <i-table border :columns="columns" :data="roleList"></i-table>
</div>
<script layout:fragment="script" th:inline="javascript">
    var mixin = {
        data: function () {
            var _that = this;
            return {
                menuActive: '0',
                roleList: [[${resourceList}]],
                columns: [
                    {
                        title: '资源路径',
                        key: 'url',
                        sortable: true,
                        width: 200
                    }, {
                        title: '备注',
                        key: 'mark',
                    },
                    {
                        title: "操作",
                        width: 150,
                        render: function (h, params) {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: {
                                        click: function () {
                                            _that.$Modal.confirm({
                                                title: '提示',
                                                content: '确定要删除吗？',
                                                onOk: function () {
                                                    _that.deleteResource(params.row.id);
                                                }
                                            });

                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ]
            }
        },
        methods: {
            addResource: function () {
                window.location.href = '/admin/resource/add';
            },
            deleteResource: function (id) {
                window.location.href = '/admin/resource/delete/' + id;
            },
            userList: function () {
                window.location.href = '/admin';
            },
            toRoleList: function () {
                window.location.href = '/admin/role';
            },
        }
    }
</script>
</body>
</html>